<!--
 * @Description: In User Settings Edit
 * @Author: your name
 * @Date: 2019-08-05 15:16:04
 * @LastEditTime: 2019-09-26 20:14:59
 * @LastEditors: Please set LastEditors
 -->
<!doctype html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport"
        content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>Hello APP</title>
    <link rel="stylesheet" type="text/css" href="../css/vant.css">
    <link rel="stylesheet" type="text/css" href="../css/base.css" />
    <script type="text/javascript" src="../script/jquery.js"></script>
    <script type="text/javascript" src="../script/vue.min.js"></script>
    <script type="text/javascript" src="../script/vant.min.js"></script>
    <script type="text/javascript" src="../script/fastclick.js"></script>
    <script type="text/javascript" src="../script/base.js"></script>
    <style type="text/css">
        .row {
            padding: 10px 10px 0 10px;
        }

        .row:last-child {
            padding-bottom: 10px;
        }

        .row>div {
            background: #fff;
            overflow: hidden;
            border-radius: 4px;
            padding: 10px;
            font-size: 14px;
        }

        .pr {
            color: #cd1b21;
        }

        .ov {
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
            font-size: 14px;
        }

        .rg {
            color: #969799;
            text-align: right;
        }

        .money {
            line-height: 40px;
        }

        .money span {
            font-size: 26px;
            font-weight: 700;
            margin-right: 5px;
        }

        .pd {
            line-height: 28px;
        }

        .pd span {
            color: #969799;
        }
    </style>
</head>

<body>
    <div id="app" v-cloak>
        <div class="init-full">
            <van-nav-bar class="head" title="在线支付记录" left-arrow @click-left="onClickLeft">

                <div slot="right" class="head-right">
                    <span @click="showSearch = true;">
                        <img src="../image/search.png" />
                    </span>
                </div>
            </van-nav-bar>
            <div class="body-no-bottom">
                <div class="content">
                    <van-list v-model="listLoading" :finished="listFinished" finished-text="没有更多了" @load="listOnLoad">
                        <div class="row" v-for="(row,index) in dataList">
                            <div>
                                <van-row gutter="20">
                                    <van-col span="12" class="ov" :class="row.PStatus == '失败'?'pr':''">支付{{row.PStatus}}
                                    </van-col>
                                    <van-col span="12" class="rg">{{row.CreateTime}}</van-col>
                                </van-row>
                                <div class="money"><span>{{row.DMoney}}</span>元</div>
                                <div class="pd">往来单位：&nbsp;&nbsp;&nbsp;&nbsp;<span>{{row.ClientName}}</span></div>
                                <div class="pd">订单编号：&nbsp;&nbsp;&nbsp;&nbsp;<span>{{row.CONTNO}}</span></div>
                                <div class="pd">支付方式：&nbsp;&nbsp;&nbsp;&nbsp;<span>{{row.PayType}}</span></div>
                                <div class="pd">支付说明：&nbsp;&nbsp;&nbsp;&nbsp;<span>{{row.ZFYY}}</span></div>
                            </div>
                        </div>
                    </van-list>
                </div>
                <van-loading v-if="showLoading" />
            </div>
        </div>

        <van-popup v-model="showSearch" round position="bottom">
            <div>
                <van-cell title="往来单位" :value="searchData.S_ClientName" is-link @click="openScreen(-1,10)">
                </van-cell>
                <van-cell title="开始时间" :value="searchData.S_SDate" @click="openDate(1)">
                </van-cell>
                <van-cell title="结束时间" :value="searchData.S_EDate" @click="openDate(2)">
                </van-cell>
            </div>
            <div class="btn-padding">
                <van-button type="primary" block style="border-radius: 0;" @click="searchList">查询</van-button>
            </div>
        </van-popup>


        <van-popup v-model="showDate" round position="bottom">
            <van-datetime-picker v-model="currentDate" type="date" @confirm="confirmDate" @cancel="cancelDate"
                cancel-button-text="清空" />
        </van-popup>


    </div>
</body>

<script type="text/javascript">
    var vm;
    apiready = function () {
        //$('.init-full').show();

        api.addEventListener({
            name: 'selectRow'
        }, function (ret, err) {
            var selectType = ret.value.selectType;
            var type = ret.value.type;
            var row = ret.value.row;
            if (selectType == 10) {
                if (row) {
                    vm.searchData.S_ClientName = row.name;
                    vm.searchData.S_ClientID = row.id;
                } else {
                    vm.searchData.S_ClientName = '';
                    vm.searchData.S_ClientID = 0;
                }

            }

        });

        var userInfo = FLD.getUserInfo();

        vm = new Vue({
            el: '#app',
            data: {
                showLoading: false,
                showSearch: false,
                listLoading: false,
                listFinished: true,
                dataList: [],
                pageIndex: 1,
                pageSize: 20,
                currentDate: new Date(),
                showDate: false,
                searchData: {
                    S_ClientID: 0,
                    S_ClientName: '',
                    S_SDate: '',
                    S_EDate: ''
                }

            },
            created: function () {
                this.getPayRecord();
            },
            methods: {
                getPayRecord() {
                    var that = this;
                    that.showLoading = true;
                    var obj = {
                        S_BranchID: userInfo.S_BranchID,
                        S_Pageindex: that.pageIndex,
                        S_PageSize: that.pageSize,
                        S_ClientID: that.searchData.S_ClientID,
                        S_SDate: that.searchData.S_SDate,
                        S_EDate: that.searchData.S_EDate
                    }
                    FLD.ajax('P_PayListNS', obj, function (res) {
                        that.showLoading = false;
                        that.listFinished = false;
                        that.dataList = res.ds;
                    })
                },
                listOnLoad(index) {
                    var that = this;
                    that.pageIndex++;
                    var obj = {
                        S_BranchID: userInfo.S_BranchID,
                        S_Pageindex: that.pageIndex,
                        S_PageSize: that.pageSize,
                        S_ClientID: that.searchData.S_ClientID,
                        S_SDate: that.searchData.S_SDate,
                        S_EDate: that.searchData.S_EDate
                    }
                    FLD.ajax('P_PayListNS', obj, function (res) {
                        that.listLoading = false;
                        if (res.ds.length == 0) {
                            that.listFinished = true;
                        }
                        that.dataList = that.dataList.concat(res.ds);
                    })
                },
                searchList() {
                    var that = this;
                    that.showSearch = false;

                    that.pageIndex = 1;

                    this.getPayRecord();
                },
                openScreen(type, index) {
                    var obj = {
                        S_Type: index,
                        S_Cont: '',
                        S_BranchID: userInfo.S_BranchID,
                        S_SXZ: '',
                        S_StockID: userInfo.S_StockID,
                        S_CargoID: userInfo.S_CargoID,
                        S_BarCode: '',
                        S_PriceN: 0,
                        S_ProductID: 0
                    }

                    api.openWin({
                        name: '筛选' + index,
                        url: 'common/baseScreen.html',
                        reload: true,
                        slidBackEnabled: false,
                        pageParam: {
                            filterData: obj,
                            type: type,
                            allowClear: true
                        }
                    })

                },
                openDate(index) {
                    dateIndex = index;
                    this.currentDate = new Date()
                    this.showDate = true;
                },
                confirmDate(value) {
                    if (dateIndex == 1) {
                        this.searchData.S_SDate = FLD.getFormatDate(value).split(' ')[0]
                    } else {
                        this.searchData.S_EDate = FLD.getFormatDate(value).split(' ')[0]
                    }
                    this.showDate = false;
                },
                cancelDate(value) {
                    if (dateIndex == 1) {
                        this.searchData.S_SDate = ''
                    } else {
                        this.searchData.S_EDate = '';
                    }
                    this.showDate = false;
                },
                onClickLeft() {
                    api.closeWin();
                }
            }
        })
    };
</script>

</html>